<%@ page import="generated.TypesForm"%>
<%@ page import="com.afc.struts.test.types.TestEnum"%>
<%@ page import="java.util.Iterator"%>
<%@ page import="com.afc.struts.utils.DateUtils"%>

<%
  String error = (String) request.getAttribute("error");
			TypesForm form = (TypesForm) request.getAttribute("form");
			if (form == null) {
				form = new TypesForm();
			}
%>

<html>
<head>
<script type="text/javascript">
	function submitForm(anActionUrl, aFormElement) {
		aFormElement.action = anActionUrl;
		aFormElement.submit();
	}
</script>
</head>

<body>
<div style="height: 50px;">
	<a href="welcome.jsp">Retour vers la page d'accueil</a>
	</div>
	<form method="post">


		<table>
			<tr>
				<td>String :</td>

				<td><input type="text" attribute-type="java.lang.String"
					name="string"
					value='<%=form.getString() != null ? form.getString() : ""%>' /></td>
			</tr>
			<tr>
				<td>TestEnum :</td>
				<td><select name="testEnum"
					attribute-type="com.afc.struts.test.types.TestEnum">
						<option value="" <%=form.getTestEnum() == null ? "selected" : ""%>></option>
						<%
						  TestEnum[] testEnums = TestEnum.values();
						  for (int i = 0; i < testEnums.length; i++)
						  {
						%>
						<option value=<%=testEnums[i].name()%>
							<%=form.getTestEnum() == testEnums[i] ? "selected" : ""%>><%=testEnums[i]%></option>
						<%
						  }
						%>
				</select></td>
			</tr>
			<tr>
				<td>int :</td>
				<td><input type="text" attribute-type="int" name="_int"
					value='<%=form.get_int()%>' /></td>
			</tr>
			<tr>
				<td>Integer :</td>
				<td><input type="text" attribute-type="java.lang.Integer"
					name="integer"
					value='<%=form.getInteger() != null ? form.getInteger() : ""%>' />
				</td>
			</tr>
			<tr>
				<td>short :</td>
				<td><input type="text" attribute-type="short" name="_short"
					value='<%=form.get_short()%>' /></td>
			</tr>
			<tr>
				<td>Short :</td>
				<td><input type="text" attribute-type="java.lang.Short"
					name="pShort"
					value='<%=form.getPShort() != null ? form.getPShort() : ""%>' /></td>
			</tr>
			<tr>
				<td>long :</td>
				<td><input type="text" attribute-type="long" name="_long"
					value='<%=form.get_long()%>' /></td>
			</tr>
			<tr>
				<td>Long :</td>
				<td><input type="text" attribute-type="java.lang.Long"
					name="pLong"
					value='<%=form.getPLong() != null ? form.getPLong() : ""%>' /></td>
			</tr>
			<tr>
				<td>double :</td>
				<td><input type="text" attribute-type="double" name="_double"
					value='<%=form.get_double()%>' /></td>
			</tr>
			<tr>
				<td>Double :</td>
				<td><input type="text" attribute-type="java.lang.Double"
					name="pDouble"
					value='<%=form.getPDouble() != null ? form.getPDouble() : ""%>' />
				</td>
			</tr>
			<tr>
				<td>float :</td>
				<td><input type="text" attribute-type="float" name="_float"
					value='<%=form.get_float()%>' /></td>
			</tr>
			<tr>
				<td>Float :</td>
				<td><input type="text" attribute-type="java.lang.Float"
					name="pFloat"
					value='<%=form.getPFloat() != null ? form.getPFloat() : ""%>' /></td>
			</tr>
			<tr>
				<td>char :</td>
				<td><input type="text" attribute-type="char" name="_char"
					value='<%=form.get_char() != 0 ? form.get_char() : ""%>' /></td>
			</tr>
			<tr>
				<td>Character :</td>
				<td><input type="text" attribute-type="java.lang.Character"
					name="character"
					value='<%=form.getCharacter() != null ? form.getCharacter() : ""%>' />
				</td>
			</tr>
			<tr>
				<td><input type="checkbox" attribute-type="boolean"
					name="_boolean" value="true"
					<%=form.get_boolean() ? "checked" : ""%>>boolean </input></td>
			</tr>
			<tr>
				<td><input type="checkbox" attribute-type="java.lang.Boolean"
					name="pBoolean" value="true"
					<%=form.getPBoolean() != null && form.getPBoolean() ? "checked" : ""%>>Boolean
					</input></td>
			</tr>
			<tr>
				<td>Object :</td>
				<td><select attribute-type="java.lang.Object"
					dao="com.afc.struts.test.data.PersonDao" name="object">
						<%
						  Iterator iterator = form.getPossibleObjects().iterator();
						  for (int i = 0; iterator.hasNext(); i++)
						  {
						    Object object = iterator.next();
						%>
						<option value=<%=i%>
							<%=object == form.getObject() ? "selected" : ""%>><%=object != null ? object : ""%></option>
						<%
						  }
						%>
				</select></td>
			</tr>
			<tr>
				<td>Date :</td>
				<td><input type="text" attribute-type="java.util.Date"
					name="date"
					value='<%=form.getDate() != null ? DateUtils.format(form.getDate()) : ""%>' />
				</td>
			</tr>
			<tr>
				<td><input type="button" value="ok"
					onclick='submitForm("types.ok.do", this.form)' /></td>
			</tr>

		</table>

		<label><%=error != null ? error : ""%></label>

	</form>

</body>

</html>